#-*- coding: utf8 -*-
from tutor.scripts import *
from tutor.plugins.sympy import *

# Entradas
with display_block('Entradas'):
    a = One * oneof(Half, sqrt(2), sqrt(3), Three/2, 2, 3)
    curve_1, is_upper = oneof((sqrt(x), True),
                           (x**2/a, False),
                           (x**4/a**2, False),
                           (a*x**(1/3), False),)

    func = Lambda(x, curve_1)
    curve_2 = func(a)/a * x
    
with display_block('Auxiliares'):
    if is_upper:
        upper, lower = curve_1, curve_2
    else: 
        upper, lower = curve_2, curve_1
        
    upper_I = upper.integrate([x, 0, a])
    lower_I = lower.integrate([x, 0, a])
    
with display_block('Respostas'):
    correta = upper_I - lower_I
    limite_superior = upper_I
    distratores = set([
        correta,
        lower_I,
        correta * a,
        correta / a,
        upper_I * a,
        upper_I / a,
        lower_I * a,
        lower_I / a,
    ])
    distratores.remove(correta)
    distratores = list(distratores)[0:6]
    assert len(distratores) >= 6
    dis_1, dis_2, dis_3, dis_4, dis_5, dis_6 = distratores 